import 'dart:convert';

import 'package:json_annotation/json_annotation.dart';
import 'package:common/model/simple_user_info/simple_user_info.dart';

part 'auth_info.g.dart';

@JsonSerializable(explicitToJson: true)
class AuthInfo {
  bool initialized = true;
  @JsonKey(
    nullable: true,
  )
  String token;

  @JsonKey(nullable: true)
  int type;
  @JsonKey(nullable: true, includeIfNull: false)
  SimpleUserInfo userInfo;

  AuthInfo({this.token, this.type, this.userInfo, this.initialized = true});

  Map<String, dynamic> toJson() => _$AuthInfoToJson(this);

  String toJsonString() {
    return json.encode(toJson()).toString();
  }

  factory AuthInfo.fromJson(Map<String, dynamic> json) =>
      _$AuthInfoFromJson(json);

}
